package user

import (
	"gitee.com/liuxuezhan/ar-platform/assets-rpc/internal/dao/schema"
)

const TableNameUserWalletLog = "user_wallet_log"

// UserWalletLog 用户钱包变更日志
type UserWalletLog struct {
	schema.Model
	OperatorId   int64   `gorm:"type:bigint;not null;default:0;comment:操作人ID;index"`
	TransferType int64   `gorm:"type:bigint;not null;comment:变更类型[1转入，2转出];index"`
	UserId       int64   `gorm:"type:bigint;not null;comment:用户id;index"`
	Amount       float64 `gorm:"type:decimal(20,4);not null;default:0;comment:金额"`
	BalanceStart float64 `gorm:"type:decimal(20,4);not null;default:0;comment:开始余额"`
	BalanceEnd   float64 `gorm:"type:decimal(20,4);not null;default:0;comment:结束余额"`
	TypeID       int64   `gorm:"type:bigint;not null;comment:变动类型[对应config_inout_type表]"`
	TypeName     string  `gorm:"type:varchar(64);not null;default:''"`
	SourceId     string  `gorm:"type:varchar(128);not null;comment:来源ID[如订单号]"`
	Description  string  `gorm:"type:varchar(255);not null;default:''"`
}

func (*UserWalletLog) TableName() string {
	return TableNameUserWalletLog
}

const (
	TRANSFER_TYPE_IN  int64 = 1 // 转入
	TRANSFER_TYPE_OUT int64 = 2 // 转出
)

var UserWalletLogTransferTypes = map[int64]string{
	TRANSFER_TYPE_IN:  "Recharge",
	TRANSFER_TYPE_OUT: "Withdrawal",
}

func (m *UserWalletLog) TransferTypeName() string {
	if name, ok := UserWalletLogTransferTypes[m.TransferType]; ok {
		return name
	}
	return ""
}
